package com.qiangesoft.rdp.starter.captcha.model;

import com.qiangesoft.rdp.starter.captcha.config.CaptchaProperties;
import com.qiangesoft.rdp.starter.captcha.constant.CaptchaTypeEnum;
import com.qiangesoft.rdp.starter.captcha.constant.CharTypeEnum;
import com.qiangesoft.rdp.starter.captcha.constant.InnerFontEnum;
import lombok.Data;

/**
 * 验证码参数
 *
 * @author qiangesoft
 * @date 2023-09-19
 */
@Data
public class CaptchaParam {

    /**
     * 文本类型
     */
    private CaptchaTypeEnum captchaType;

    /**
     * 验证码文本类型
     */
    private CharTypeEnum charType;

    /**
     * 验证码图片宽度
     */
    private int width;

    /**
     * 验证码图片高度
     */
    private int height;

    /**
     * 验证码文本长度
     */
    private int length;

    /**
     * 字体
     */
    private InnerFontEnum fontType = InnerFontEnum.FONT_1;

    /**
     * 字体风格
     */
    private int fontStyle = 1;

    /**
     * 字体大小
     */
    private int fontSize = 15;

    /**
     * toQuery
     *
     * @param captchaProperties
     * @return
     */
    public static CaptchaParam toQuery(CaptchaProperties captchaProperties) {
        CaptchaParam param = new CaptchaParam();
        param.setCaptchaType(captchaProperties.getCaptchaType());
        param.setCharType(captchaProperties.getCharType());
        param.setWidth(captchaProperties.getWidth());
        param.setHeight(captchaProperties.getHeight());
        param.setLength(captchaProperties.getLength());
        param.setFontType(captchaProperties.getFontType());
        param.setFontStyle(captchaProperties.getFontStyle());
        param.setFontSize(captchaProperties.getFontSize());
        return param;
    }

}
